class ConPawn extends UTPawn;

// Kyle: Idea to replace and rename Pawn.uc's function from BattleTeamArena
function bool Pawn_Died(Controller Killer, class<DamageType> damageType, vector HitLocation)
{
	local SeqAct_Latent Action;
	
	// Kyle: Flag the pawn as dead
	ConPRI (PlayerReplicationInfo).bConDead = true;
	ConPRI (PlayerReplicationInfo).bRecentlyDead = true;
	
	// allow the current killer to override with a different one for kill credit
	if ( Killer != None )
	{
		Killer = Killer.GetKillerController();
	}
	// ensure a valid damagetype
	if ( damageType == None )
	{
		damageType = class'DamageType';
	}
	// if already destroyed or level transition is occuring then ignore
	if ( bDeleteMe || WorldInfo.Game == None || WorldInfo.Game.bLevelChange )
	{
		return FALSE;
	}
	// if this is an environmental death then refer to the previous killer so that they receive credit (knocked into lava pits, etc)
	if ( DamageType.default.bCausedByWorld && (Killer == None || Killer == Controller) && LastHitBy != None )
	{
		Killer = LastHitBy;
	}
	// gameinfo hook to prevent deaths
	// WARNING - don't prevent bot suicides - they suicide when really needed
	if ( WorldInfo.Game.PreventDeath(self, Killer, damageType, HitLocation) )
	{
		Health = max(Health, 1);
		return false;
	}
	Health = Min(0, Health);
	// activate death events
	TriggerEventClass( class'SeqEvent_Death', self );
	// and abort any latent actions
	foreach LatentActions(Action)
	{
		Action.AbortFor(self);
	}
	LatentActions.Length = 0;
	// notify the vehicle we are currently driving
	if ( DrivenVehicle != None )
	{
		Velocity = DrivenVehicle.Velocity;
		DrivenVehicle.DriverDied();
	}
	else if ( Weapon != None )
	{
		Weapon.HolderDied();
		ThrowActiveWeapon();
	}
	// notify the gameinfo of the death
	if ( Controller != None )
	{
		WorldInfo.Game.Killed(Killer, Controller, self, damageType);
	}
	else
	{
		WorldInfo.Game.Killed(Killer, Controller(Owner), self, damageType);
	}
	DrivenVehicle = None;
	// notify inventory manager
	if ( InvManager != None )
	{
		InvManager.OwnerEvent('died');
		// and destroy
		InvManager.Destroy();
		InvManager = None;
	}
	// push the corpse upward (@fixme - somebody please remove this?)
	Velocity.Z *= 1.3;
	// if this is a human player then force a replication update
	if ( IsHumanControlled() )
	{
		PlayerController(Controller).ForceDeathUpdate();
	}
	NetUpdateFrequency = Default.NetUpdateFrequency;
	PlayDying(DamageType, HitLocation);
	return TRUE;
}

function bool Died(Controller Killer, class<DamageType> damageType, vector HitLocation) // Derived from UTPawn.uc
{
	if (Pawn_Died(Killer, DamageType, HitLocation))
	{
		StartFallImpactTime = WorldInfo.TimeSeconds;
		bCanPlayFallingImpacts=true;
		if(ArmsMesh[0] != none)
		{
			ArmsMesh[0].SetHidden(true);
			if(ArmsOverlay[0] != none)
			{
				ArmsOverlay[0].SetHidden(true);
			}
		}
		if(ArmsMesh[1] != none)
		{
			ArmsMesh[1].SetHidden(true);
			if(ArmsOverlay[1] != none)
			{
				ArmsOverlay[1].SetHidden(true);
			}
		}
		SetPawnAmbientSound(None);
		SetWeaponAmbientSound(None);
		return true;
	}
	return false;
}

defaultproperties
{
   Name="ConPawn"
}
